package com.gem.day14;

import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 本类用来演示PrintWriter
 * 
 * @author easonsy
 * 2020年8月6日 下午2:24:46
 */
public class PrintWriterDemo {
	public static void main(String[] args) {
		//try (PrintWriter pw = new PrintWriter("D:\\log.txt"); Scanner scanner = new Scanner(System.in)) {

		/*
		 * 注意:
		 * FileWriter构造方法第二个参数表示是否开启追加模式
		 * PrintWriter构造第二个参数表示是否自动刷新缓存
		 */
		try (PrintWriter pw = new PrintWriter(new FileWriter("D:\\log.txt", true), true);
				Scanner scanner = new Scanner(System.in)) {
			System.out.println("请您输入内容: ");
			String input = scanner.nextLine();
			pw.println(input);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
